import React, { Component } from 'react'
import PropTypes from 'prop-types'

export default class Text extends Component {
  render () {
    const { value, format, empty = '无' } = this.props
    return (
      <span>{format ? (format(value) || empty) : (value || empty)}</span>
    )
  }
}

Text.propTypes = {
  format: PropTypes.func
}

Text.defaultProps = {
  format: null
}
